//
//  DoorUserViewController.m
//  RONGAO
//
//  Created by wei wang on 2017/2/23.
//  Copyright © 2017年 wei wang. All rights reserved.
//

#import "DoorUserViewController.h"
#import "RunModeViewController.h"
#import "GatherViewController.h"
#import "PassWordController.h"
#import "DoorOpenDistanceViewController.h"
#import "BindCameraViewController.h"
@interface DoorUserViewController ()<UITableViewDelegate,UITableViewDataSource>

/** titleArray **/
@property(nonatomic,strong) NSArray *titleArray;
/** tableView **/
@property(nonatomic,strong) UITableView *tableView;
@end

@implementation DoorUserViewController

- (void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setNavigationStyle];
    [self masLayoutSubview];
}
- (void)setNavigationStyle{
    
    [self setNavigationTitle:@"用户设置" titleColor:nil];
    [self setLeftButtonImage:[UIImage imageNamed:@"icon_back_nor"]];
    
}
-(void)onLeftButtonClick:(id)sender{
    
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - --------------------------UITableView dataSource--------------------------

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.titleArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        cell.textLabel.textColor = [UIColor colorWithHexString:@"#56504f"];
        [cell.textLabel setFont:[UIFont systemFontOfSize:15.f]];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.textLabel.text = self.titleArray[indexPath.row];
    
    return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 56;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    
    return CGFLOAT_MIN;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return CGFLOAT_MIN;
    
}
#pragma mark - --------------------------UITableView delegate--------------------------

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        
        RunModeViewController *vc = [RunModeViewController new];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if (indexPath.row == 1){
        
        GatherViewController *vc = [GatherViewController new];
        vc.hidesBottomBarWhenPushed = YES;
        [vc setGatherVCTitleAndPickerType:12];
        vc.selectIndex = 12;
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if (indexPath.row == 2){
        
        GatherViewController *vc = [GatherViewController new];
        vc.hidesBottomBarWhenPushed = YES;
        vc.selectIndex = 13;
        [vc setGatherVCTitleAndPickerType:13];
        
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if (indexPath.row == 3){//摄像头
        
        BindCameraViewController *vc = [BindCameraViewController new];
        [self.navigationController pushViewController:vc animated:YES];

        
    }else if (indexPath.row == 4){//开关度
        
        DoorOpenDistanceViewController *vc = [DoorOpenDistanceViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    }

}


- (NSArray *)titleArray{
    
    if (!_titleArray) {
        
        _titleArray = @[@"运行模式",@"速度调节",@"开门停留时间",@"摄像头设置",@"开关度设置"];
        
    }
    
    return _titleArray;
}

- (UITableView *)tableView{
    
    if (!_tableView) {
        
        __weak UIView *superView = self.view;
        _tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        [superView addSubview:_tableView];
        //        _tableView.separatorStyle = UITableViewCellSelectionStyleNone;//隐藏tableView的分割线
        //        _tableView.scrollEnabled = NO;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        
    }
    
    return _tableView;
    
}

- (void)masLayoutSubview{
    
    __weak UIView *superView = self.view;
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.mas_equalTo(superView);
        
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
